package com.hq.erp.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.hq.erp.model.Product;

public interface ProductMapper {

	@Insert("insert into baseinf_product"
			+ "(product_id,product_number,product_name,product_specification,product_message) "
			+ "values(#{productId},#{productNumber},#{productName},#{productSpecification},#{productMessage})")
	public void insertProduct(Product product);

	@Update("update baseinf_product set "
			+ "product_number=#{productNumber},product_name=#{productName},product_specification=#{productSpecification},product_message=#{productMessage} "
			+ "where product_id=#{productId}")
	public void updateProduct(Product product);

	@Delete("delete from baseinf_product where product_id=#{productId}")
	public void deleteProduct(String productId);

	@Select("select product_id,product_number,product_name,product_specification,product_message from baseinf_product "
			+ "where product_id=#{productId}")
	@Results(id = "productMapper", value = { @Result(column = "product_id", property = "productId", id = true),
			@Result(column = "product_number", property = "productNumber"),
			@Result(column = "product_name", property = "productName"),
			@Result(column = "product_specification", property = "productSpecification"),
			@Result(column = "product_message", property = "productMessage") })
	public Product findProductById(String productId);

	@Select("select product_id,product_number,product_name,product_specification,product_message from baseinf_product")
	@ResultMap("productMapper")
	public List<Product> findProducts();

}
